package com.mianyang.zhangsan.service.impl;

import com.mianyang.zhangsan.service.ISecSpringContextService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author jiangjr
 * @date 2022-10-25
 */
@Component
public class ISecSpringContextServiceImpl implements ISecSpringContextService, ApplicationContextAware {
    private ApplicationContext applicationContext;

    @Override
    public Object getBean(String beanName, Class<?> type) {
        return applicationContext.getBean(beanName, type);
    }

    @Override
    public Object getBean(String beanName) {
        return applicationContext.getBean(beanName);
    }

    @Override
    public ApplicationContext getContext() {
        return this.applicationContext;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
